package manager.orders.controller;
import com.github.pagehelper.PageInfo;
import manager.orders.service.OrderService;
import manager.orders.vo.OrderVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = {"/customer/order"})
public class OrderCustomerController {
    @Autowired
    private OrderService orderService;

    //新增订单
    @PostMapping("add")
    public ResponseEntity<OrderVO> addOrder(@RequestBody OrderVO orderVO){
         //添加订单
         orderService.addOrder(orderVO);
         return ResponseEntity.ok(orderVO);
    }
    @PostMapping("list")
    public PageInfo<OrderVO> getOrderByCondition(@RequestBody OrderVO orderVO){
        //添加订单
        PageInfo<OrderVO> orderResult=orderService.getOrderByCondition(orderVO);
        return orderResult;
    }
    //删除订单
    @PostMapping("delete")
    public ResponseEntity<Void> deleteOrder(@RequestBody OrderVO orderVO){
        //添加订单
        orderService.deleteOrder(orderVO);
        return ResponseEntity.ok().build();
    }
    //修改订单状态
    @PostMapping("update")
    public ResponseEntity<Void> updateOrder(@RequestBody OrderVO orderVO){
        //添加订单
        orderService.updateOrder(orderVO);
        return ResponseEntity.ok().build();
    }
}
